package com.JZ.QM.service.impl;

import com.JZ.QM.common.entity.ShareInfoEntity;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.JZ.QM.common.utils.PageUtils;
import com.JZ.QM.common.utils.Query;

import com.JZ.QM.common.dao.FdShareInfoDao;
import com.JZ.QM.common.entity.FdShareInfoEntity;
import com.JZ.QM.service.FdShareInfoService;

import javax.annotation.Resource;

/**
 *
 *
 * @author lyp
 * @email lyp@gmail.com
 * @date 2020-06-14 11:19:36
 */
@Service("fdShareInfoService")
public class FdShareInfoServiceImpl extends ServiceImpl<FdShareInfoDao, FdShareInfoEntity> implements FdShareInfoService {

    @Resource
    FdShareInfoDao fdShareInfoDao;

    /**
     * @param params
     * @return
     * @throws Exception
     */
    @Override
    public PageUtils queryPage(Map<String, Object> params) throws Exception {
        IPage<FdShareInfoEntity> page = this.page(
                new Query<FdShareInfoEntity>().getPage(params),
                new QueryWrapper<FdShareInfoEntity>()
        );
        return new PageUtils(page);
    }
    /**
     * 根据策略Id筛选出基金列表
     * @param fdShareInvestType 基金投资风格
     * @param fdShareType 基金类型
     * @param fdShareScaleMin 基金规模下限
     * @param fdShareScaleMax 基金规模上限
     * @return
     */
    @Override
    public List<FdShareInfoEntity> filtrateFdShareList(Integer fdShareInvestType, Integer fdShareType, BigDecimal fdShareScaleMin, BigDecimal fdShareScaleMax) {
        //条件构造器
        QueryWrapper<FdShareInfoEntity> queryWrapper = new QueryWrapper<>();
        //基金列表
        List<FdShareInfoEntity> fdShareInfoEntities=new ArrayList<>(10);

        //条件构造器封装复杂查询
        queryWrapper.eq("fd_share_invest_type",fdShareInvestType)
                    .eq("fd_share_type",fdShareType)
                    .between("fd_share_scale",fdShareScaleMin,fdShareScaleMax);

        fdShareInfoEntities =fdShareInfoDao.selectList(queryWrapper);

        return fdShareInfoEntities;
    }

}